package cn.e4j.modular.system.service.impl;

import cn.e4j.core.dto.impl.Dto;
import cn.e4j.modular.system.entity.SysLoad;
import cn.e4j.modular.system.mapper.SysLoadMapper;
import cn.e4j.modular.system.service.SysLoadService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuan_rz
 * @since 2019-03-12
 */
@Service("sysLoadService")
public class SysLoadServiceImpl extends ServiceImpl<SysLoadMapper, SysLoad> implements SysLoadService {
    @Transactional(readOnly = true)
    public List<SysLoad> getListData(Page<Object> page, Dto dto) {
        List<SysLoad> listData = this.baseMapper.getListData(page, dto);
        return listData;
    }

    @Transactional(readOnly = true)
    public List<SysLoad> getListData(Dto dto) {
        List<SysLoad> listData = this.baseMapper.getListData(dto);
        return listData;
    }

    @Transactional
    public void addData(SysLoad sysLoad){
        //新增
        sysLoad.insert();
    }

    @Transactional
    public void editData(SysLoad sysLoad){
        sysLoad.updateById();
    }

    @Transactional
    public void deleteData(SysLoad sysLoad){
        delete(sysLoad);
    }

    @Transactional
    public void deleteDataBatch(List<SysLoad> sysLoadList){
        for(int i=0; i < sysLoadList.size(); i++){
            delete(sysLoadList.get(i));
        }
    }


    private void delete(SysLoad sysLoad){
        sysLoad.deleteById();
    }
}
